import os
import pandas as pd
import time


class Report:
    def __init__(self):
        columns = ['Apk', 'Type', 'Start Time', 'End Time', 'Duration', 'Status', 'Reason']
        self.df = pd.DataFrame(columns=columns)

    def add_record(self, record):
        # record = {
        #     'Apk': apk_name, 'Type': type, 'Start Time': start_time, 'End Time': end_time,
        #     'Status': status, 'Reason': reason
        # }
        new_row = pd.DataFrame([record])
        self.df = pd.concat([self.df, new_row], ignore_index=True)
        return True

    def create_report(self, path):
        end_time = time.strftime("%Y-%m-%d %H-%M-%S", time.localtime())
        report_path = os.path.join(path, f'Report-{end_time}.csv')
        self.df.to_csv(report_path, index=False)
        return True